<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/8 0008
  Time: 23:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>管理员列表</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->
    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/translateelement.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->
    <!-- 公共的js -->
    <script src="${baseurl}statics/assets/js/common.js"></script>
    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->

</head>

<body>

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">系统管理</a>
        </li>

        <li>
            <a href="${baseurl}sysUserController/findPageAllSysUser">管理员管理</a>
        </li>
        <li class="active">管理员列表</li>
    </ul><!-- .breadcrumb -->


</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">管理员列表</h3>
                    <div class="table-header">
                        管理员列表信息
                    </div>

                    <div class="table-responsive">

                        <div style="width: 25%;" class="system_top_l clearfix">
                            <form class="form-search" action="${baseurl}sysUserController/findPageAllSysUser" method="post">
                                <div class="row" style="margin-top: 10px;float: left;">
                                    <div class="col-xs-12 col-sm-8">
                                        <div class="input-group">
                                            <shiro:hasPermission name="sysuser:findAll">
                                            <input type="text" class="form-control search-query" name="keywords"
                                                   placeholder="请输入管理员名称" value="${keywords}"/>
                                            </shiro:hasPermission>
                                            <span class="input-group-btn">
                                                    <button type="submit"
                                                            class="btn btn-purple btn-sm">
                                                        搜索
                                                        <i class="icon-search icon-on-right bigger-110"></i>
                                                    </button>
                                                </span>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div style="float: left;margin-top: 10px;" class="system_top_r clearfix">
                            <shiro:hasPermission name="sysuser:add">
                            <div id="inPermission">
                                <a class="btn btn-purple btn-sm" href="${baseurl}sysUserController/toAdd"
                                   >添加管理员</a>
                            </div>
                            </shiro:hasPermission>
                        </div>
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                               style="padding-top: 40px;">
                            <thead>
                            <tr>
                                <th class="center">
                                    <label>
                                        <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th style="text-align: center">管理员id</th>
                                <th style="text-align: center">管理员名称</th>
                                <%--<th class="hidden-480">手机号</th>--%>
                                <th style="text-align: center">管理员角色</th>
                                <th style="text-align: center">是否启用</th>
                                <th style="text-align: center">
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    添加时间
                                </th>
                                <%--<th class="hidden-480">用户状态</th>--%>
                                <th style="text-align: center">操作</th>
                            </tr>
                            </thead>

                            <tbody>
                            <c:forEach items="${page.records}" var="sysUser">
                                <tr>
                                    <td class="center" style="vertical-align: middle;height: 50px">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>

                                    <td style="text-align: center;vertical-align: middle;;height: 50px">
                                        <a href="#">${sysUser.id}</a>
                                    </td>
                                    <td style="text-align: center;vertical-align: middle;height: 50px">${sysUser.userName}</td>
                                    <td style="text-align: center;vertical-align: middle;height: 50px"><c:forEach items="${sysRoles}" var="role">
                                         <c:if test="${role.id == sysUser.roleId}">
                                             ${role.roleName}
                                         </c:if>
                                         </c:forEach>
                                    </td>
                                    <td style="text-align: center;vertical-align: middle;height: 50px"><c:if test="${sysUser.userStatus == 0}"><span style="color: green;font-weight: bold;">已启用</span></c:if>
                                        <c:if test="${sysUser.userStatus == 1}"><span style="color: red;font-weight: bold;">已禁用</span></c:if></td>
                                    <%--<td class="hidden-480">${user.userPhone}</td>--%>
                                    <td style="text-align: center;vertical-align: middle;height: 50px"><fmt:formatDate value="${sysUser.createTime}"
                                                        pattern="YYYY年M月d日 h:mm:ss"></fmt:formatDate></td>
                                    <td style="text-align: center;vertical-align: middle;height: 50px">
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                           <%-- <a class="blue" href="${baseurl}sysUserController/toAdd">
                                                <i class="icon-zoom-in bigger-130"></i>
                                            </a>--%>
                                               <shiro:hasPermission name="sysuser:update">
                                                <a class="green" href="${baseurl}sysUserController/toUpdate?sysUserId=${sysUser.id}" title="修改">
                                                    修改
                                                </a>
                                               </shiro:hasPermission>
                                               <shiro:hasPermission name="sysuser:isenable">
                                               <c:if test="${sysUser.userStatus == 0 && sysUser.id != 1}">
                                               <a class="btn btn-pink btn-sm" href="javascript:onclick = updateStatus('${sysUser.id}','${sysUser.userStatus}');">禁用</a>
                                               </c:if>
                                               <c:if test="${sysUser.userStatus == 1}">
                                                   <a class="btn btn-purple btn-sm" href="javascript:onclick = updateStatus('${sysUser.id}','${sysUser.userStatus}');">启用</a>
                                               </c:if>
                                               </shiro:hasPermission>
                                               <shiro:hasPermission name="sysuser:delete">
                                            <a class="red" href="javascript:onclick = del(${sysUser.id});" title="删除">
                                              删除
                                            </a>
                                               </shiro:hasPermission>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/common/pageHelper.jsp"/>
                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>


<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
    function del(id) {
        var k = window.confirm("确定是否要删除！");
        if (k) {
            $.ajax({
                url: "${baseurl}sysUserController/delete",
                data:{"sysUserId":id},
                type: "post",
                success: function (json) {
                    if(json.code == "0"){
                        alert(json.message);
                        location.reload();
                    }else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }
    function updateStatus(id,status) {
        var k = null;
        if(status == 0){
           k = window.confirm("确定是否要禁用");
        }else{
            k = window.confirm("确定是否要启用");
        }
        if (k) {
            $.ajax({
                url: "${baseurl}sysUserController/updateStatus",
                data:{"sysUserId":id},
                type: "post",
                success: function (json) {
                    if(json.code == "0"){
                        alert(json.message);
                        location.reload();
                    }else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    jQuery(function ($) {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null, null,
                {"bSortable": false}
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });
        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table');
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })
</script>
</body>
</html>
